package com.jinmdz.fmis.dao.dao;

import com.jinmdz.fmis.dao.dao.provider.FarewellMournHallProvider;
import com.jinmdz.fmis.dao.model.farewell.FarewellMournDeadItem;
import com.jinmdz.fmis.dao.model.farewell.FarewellMournHallDeadItem;
import com.jinmdz.fmis.dao.model.farewell.FarewellMournHallItem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;

import java.util.ArrayList;
import java.util.Date;

/**
 * 告别房间Dao
 *
 * @author LiCongLu
 * @date 2020-02-15 14:48
 */
public interface FarewellMournHallDao {

    /**
     * 按照主键获取礼厅房间信息
     *
     * @param id 主键
     * @return
     * @author LiCongLu
     * @date 2020-02-15 14:48
     */
    @Select(" select id,hall_type_code,hall_code,hall_name,hall_describe,hall_state,as_wake,as_farewell,disable_state,sort,remark,version" +
            " from mourn_ceremony_hall where id = #{id} and deleted=0 ")
    FarewellMournHallItem getFarewellMournHallById(@Param("id") Integer id);

    /**
     * 按照类型字典编码值查询礼厅房间信息
     *
     * @param dataCode           类型编码
     * @param outState           出厅状态
     * @param inState            入厅状态
     * @param appointmentInTime  预约入厅时间
     * @param appointmentOutTime 预约出厅时间
     * @param asWake             是否守灵
     * @param asFarewell         是否告别
     * @return
     * @[param asWake  是否守灵
     * @author LiCongLu
     * @date 2020-02-17 17:56
     */
    @SelectProvider(type = FarewellMournHallProvider.class, method = "listFarewellMournHallDeadByDataCode")
    ArrayList<FarewellMournHallDeadItem> listFarewellMournHallDeadByDataCode(@Param("dataCode") Integer dataCode, @Param("outState") Integer outState, @Param("inState") Integer inState, @Param("appointmentInTime") Date appointmentInTime, @Param("appointmentOutTime") Date appointmentOutTime, @Param("asWake") Integer asWake, @Param("asFarewell") Integer asFarewell);

    /**
     * 按照礼厅主键获取逝者信息
     *
     * @param hallIds           礼厅主键集合
     * @param appointmentInTime 预约入厅时间
     * @return
     * @author LiCongLu
     * @date 2020-03-08 20:23
     */
    @SelectProvider(type = FarewellMournHallProvider.class, method = "listFarewellMournDeadByHallIds")
    ArrayList<FarewellMournDeadItem> listFarewellMournDeadByHallIds(@Param("hallIds") ArrayList<Integer> hallIds, @Param("appointmentInTime") Date appointmentInTime);

    /**
     * 更新状态值
     *
     * @param state          状态值
     * @param modifiedUserId 修改帐号
     * @param id             主键
     * @param version        版本号
     * @return
     * @author LiCongLu
     * @date 2020-02-17 17:24
     */
    @Update(" update mourn_ceremony_hall set hall_state = #{state},modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void updateStateById(@Param("state") Integer state, @Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);
}
